﻿#include "GuninfoSetting.h"
#include "ui_guninfosetting.h"

GuninfoSetting::GuninfoSetting(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::GuninfoSetting)
{
    ui->setupUi(this);
    time = new QLabel(ui->frameBottom);
    time->setGeometry(10, 10, 200, 40);
    time->setStyleSheet("QLabel{font: 20px; color: rgb(25, 25, 112);}");
    signal = new QLabel(ui->frameBottom);
    signal->setGeometry(700, 18, 41, 22);
    signal->setStyleSheet("QLabel{background-color:transparent;}");

    QDir dir(IMAGE_PATH);
    if(dir.exists())
    {
        ui->frameTop->setStyleSheet(LOGO_STY);
    }

    ButtonArray[0] = ui->buttonChooseGunnum1;
    ButtonArray[1] = ui->buttonChooseGunnum2;
    ButtonArray[2] = ui->buttonChooseGunnum3;
    ButtonArray[3] = ui->buttonChooseGunnum4;
    ButtonArray[4] = ui->buttonChooseGunnum5;
    ButtonArray[5] = ui->buttonChooseGunnum6;
    ButtonArray[6] = ui->buttonChooseGunnum7;
    ButtonArray[7] = ui->buttonChooseGunnum8;
    for(int i=0; i<GUN_AMOUNT; i++)
    {
        connect(ButtonArray[i], SIGNAL(clicked()), this, SLOT(ChooseGuninfoChange()));
    }
    for(int i=GUN_AMOUNT; i<8; i++)
    {
        ButtonArray[i]->hide();
    }
}

GuninfoSetting::~GuninfoSetting()
{
    delete ui;
}
void GuninfoSetting::ChooseGuninfoChange()
{
    QPushButton* btn =  static_cast<QPushButton*>(sender());
    for(int i=0; i<8; i++)
    {
        if(btn == ButtonArray[i])
        {
            emit SetGuninfo(i);
            stackLayout->setCurrentIndex(ChangeguninfoPage);
        }
    }
}
void GuninfoSetting::on_buttonBack_clicked()
{
    stackLayout->setCurrentIndex(SystemSetting4Page);
}
